<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
    $("#contentTable").treeTable();

    function delLoad(divId, url) {
        $.ajax({
            type: "POST",
            url: url,
            dataType: "json",
            success: function (data) {
                if (data.code == "success") {
                    toastr.success(data.data);
                    $('#searchForm').submit();
                } else if (data.code == "info") {
                    toastr.info(data.data);
                } else {
                    toastr.error(data.data);
                }
            },
            error: function (data) {
                toastr.error('网络连接错误,请检查网络');
            }
        });
    }
    //检验查看
    function labResult(url){
        layerIndex =layer.open({
            type: 2,
            title:'检验单查看',
            area: ['60%', '50%'],
            fixed: false, //不固定
            maxmin: true,
            content: url,
            btn: ['关闭'],
            yes:function(index,layero){
                layer.close(index);
            }
        });
    }
 </script>
<div class="content-wrap">
    <div class="wrapper" style="bottom: 50px;">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#">检验确认列表</a>
            </li>
            <li>
                <a href="#" onclick="loadByUrl('${ctx}/lab/labApply/waitFeeData')">检验诊间收费</a>
            </li>
        </ul>
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <form:form id="searchForm" modelAttribute="labApply"  onsubmit="return loadDivForm('mainCenterDiv','searchForm','${ctx}/lab/labApply/labConfirm');" method="post" class="form-inline">
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                                <form:radiobutton path="inoroutFlag" onclick="$('#searchForm').submit();" value="0"></form:radiobutton>&nbsp;<label>门诊</label>&nbsp;&nbsp;
                                <form:radiobutton path="inoroutFlag" onclick="$('#searchForm').submit();" value="1"></form:radiobutton>&nbsp;<label>住院</label>&nbsp;
                                <label>申请科室 ：</label><sys:treeselect selectedParent="false" id="orgDeptId" name="billingDept"  value="${labApply.billingDept}"  update="false" labelName="implementDeptEt.deptName" labelValue="${labApply.implementDeptEt.deptName}"
                                                                      title="科室" url="/sys/orgDept/treeData" extId="" cssClass="form-control" />
                                <label>姓名：</label><form:input path="name"  htmlEscape="false" class="form-control" />
                                <label>状态</label>:
                                <form:select path="confirmFlag" class="form-control">
                                    <form:option value="0" selected="selected">未确认</form:option>
                                    <form:option value="1">已确认</form:option>
                                </form:select>

                                <input id="search" class="btn btn-primary" type="submit" value="查询"/>&nbsp;&nbsp;
                            </form:form>
                        </div>
                    </div>
                    <table id="contentTable" class="table table-bordered mg-t datatable">
                        <thead>
                        <tr>
                            <th>姓名</th>
                            <th>申请时间</th>
                            <th>申请序号</th>
                            <th>申请科室</th>
                            <th>执行科室</th>
                            <th>收费标识</th>
                            <th>确认标识</th>
                            <th>申请医生</th>
                           <%-- <th>标本</th>--%>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody >
                        <c:forEach items="${page.list}" var="lab" varStatus="ss">
                            <tr id="${lab.id}" >
                                <td>${lab.patMasterIndex.name}</td>
                                <td> <fmt:formatDate value="${lab.createDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate> </td>
                                <td> ${lab.applyOn}</td>
                                <td> ${lab.billingDeptEt.deptName}</td>
                                <td> ${lab.implementDeptEt.deptName}</td>
                                <td>${fns:getDictLabels(lab.chargeFlag,'NO_CHARGE','')}</td>
                                <td>${fns:getDictLabels(lab.confirmFlag,'CONFIRM_DICT','')}</td>
                                <td> ${lab.createBy.name}</td>
                              <%--  <td> ${lab.specimen }</td>--%>
                                <td>
                                    <c:if test="${lab.confirmFlag=='0'}">
                                        <a href="#"  class="applyBt btn btn-danger btn-xs" onclick="confirmExtend('确认要执行吗？',function(){delLoad('mainCenterDiv','${ctx}/lab/labApply/labConfirmDo?id=${lab.id}','${ctx}/lab/labApply/labConfirm')})">确认</a>
                                    </c:if>
                                    <c:if test="${lab.confirmFlag=='1'}">
                                        <a href="#" class="btn btn-warning btn-xs"
                                           onclick="labResult('${ctx}/doctor/lab/labResult/index?testNo=${lab.applyOn}')">检验查看</a>
                                        <a href="#"  class="applyBt btn btn-danger btn-xs" onclick="confirmExtend('确认要取消操作吗？',function(){delLoad('mainCenterDiv','${ctx}/lab/labApply/cancelExamConfirmDo?id=${lab.id}','${ctx}/lab/labApply/labConfirm')})">取消确认</a>
                                    </c:if>
                                    <c:if test="${lab.confirmFlag=='1'&& lab.chargeFlag=='5' && lab.confirmFlag=='1'}">
                                        <a href="#"  class="btn btn-warning btn-xs"  onclick="confirmExtend('确认要退费？',function(){delLoad('mainCenterDiv','${ctx}/lab/labApply/retChargeOk?applyId=${lab.id}')})">确认退费</a>
                                    </c:if>
                                    <c:if test="${examApply.chargeFlag eq 2  && examApply.confirmFlag=='1'}">
                                        ${fns:getDictLabels(examApply.chargeFlag,'NO_CHARGE','')}
                                    </c:if>
                                </td>
                            </tr>
                            <c:if test="${lab.labItemList.size()>0}">
                                <tr id="${ss.count}" pid="${lab.id}">
                                    <td colspan="9">
                                        <table id="printbtn" class="table table-bordered mg-t  ">
                                            <tr>
                                                <th>序号</th>
                                                <th>项目名称</th>
                                                <th>项目编码</th>
                                                <th>费用</th>
                                             </tr>
                                            <c:forEach items="${lab.labItemList}" var="item" varStatus="ss">
                                                <tr>
                                                    <td> ${ss.count}</td>
                                                    <td> ${item.itemName}</td>
                                                    <td> ${item.itemCode}</td>
                                                    <td> ${item.costs}</td>
                                                </tr>
                                            </c:forEach>
                                        </table>
                                    </td>
                                </tr>
                            </c:if>
                        </c:forEach>
                    </table>
                    <div class="pagination">${page}</div>
                </div>
            </div>
        </section>
        <input type="hidden" id="radioVal" value="${labApply.inoroutFlag}">
     </div>
</div>